package Jona;

public class Negation implements ArgObject {
	
	ArgObject originalStatement;
	// Added
	boolean conflictSolved = false;
	public boolean addedInformation = false;
	int conflictValue = UNDEFINED;
	
	public Negation(ArgObject negatedStatement)	{
		this.originalStatement = negatedStatement;
	}
	
	public boolean isAttackerOf(ArgObject st) {
		return originalStatement.isSupporterOf(st);
	}
	
	public boolean isAttackedBy(ArgObject st) {
		return originalStatement.isSupportedBy(st);
	}
	
	public boolean isSupporterOf(ArgObject st) {
		return originalStatement.isAttackerOf(st);
	}
	
	public boolean isSupportedBy(ArgObject st) {
		return originalStatement.isAttackedBy(st);
	}
	
	public void addAttackingConditional(ArgObject attacker){
		originalStatement.addSupportingConditional(attacker);
	}
	
	public void addAttacker(ArgObject attacker) {
		originalStatement.addSupporter(attacker);
	}

	public void addSupportingConditional(ArgObject supporter){
		originalStatement.addAttackingConditional(supporter);
	}
	
	public void addSupporter(ArgObject supporter) {
		originalStatement.addAttacker(supporter);
	}
	
	public ArgObject[] getAttackers(){
		return originalStatement.getSupporters();
	}

	public ArgObject[] getAttackingConditionals(){
		return originalStatement.getSupportingConditionals();
	}
	
	public void removeSupporter(ArgObject supporter) {
		originalStatement.removeAttacker(supporter);
	}

	public void removeAttacker(ArgObject attacker) {
		originalStatement.removeSupporter(attacker);
	}

	public void removeAttackingConditional(ArgObject attacker) {
		originalStatement.removeSupportingConditional(attacker);
	}
	
	public void removeAllAttackers() {
		originalStatement.removeAllSupporters();
	}

	public ArgObject[] getSupporters(){
		return originalStatement.getAttackers();
	}

	public ArgObject[] getSupportingConditionals(){
		return originalStatement.getAttackingConditionals();
	}
	
	public void removeSupportingConditional(ArgObject supporter) {
		originalStatement.removeAttackingConditional(supporter);
	}
	
	public void removeAllSupporters() {
		originalStatement.removeAllAttackers();
	}

	public void setArgumentType(int type){
		originalStatement.setArgumentType(type);
	}
	
	public int getArgumentType(){
		return originalStatement.getArgumentType();
	}
	
	public String getText(){
		return "IT IS NOT THE CASE THAT "+originalStatement.getText();
//		return "not("+originalStatement.getText()+")";
	}

	public void setText(String newText){
		originalStatement.setText(newText);
	}
	
	public int evaluate(Theory th) {
		int valOrg;
		valOrg = -th.evaluate(originalStatement);
		if (valOrg == -ArgObject.EVALUATION_UNASSIGNED) {
			valOrg = th.getValue(this);
		} 
		if (valOrg == ArgObject.EVALUATION_UNASSIGNED || valOrg == ArgObject.EVALUATION_UNKNOWN) {
			valOrg = -originalStatement.evaluate(th);
		}
		return valOrg;
	}
	
	public ArgObject getNegation(){
		return originalStatement;
	}

	public ArgObject giveCopy() {
		ArgObject rt = originalStatement.giveCopy().getNegation();		
		
		return rt;
	}
	
	public String getName() {
		return "!"+originalStatement.getName();
	}
	
	public void setName(String newName) {
		originalStatement.setName(newName);
	}
	
	public boolean hasName()
    {
    	return getName()!=null;
    }


	public String getUnparsedText()
	{
		return originalStatement.getUnparsedText();
	}

	public String toString()
	{
		String rt ="";
		if(getArgumentType() == ASSUMPTION) rt += "S:";
		else if(getArgumentType() == ISSUE) rt += "I:";
		else if(getArgumentType() == UNDEFINED) rt += "U:";
		rt+= getText();
		return rt;
	}

	public void addedInformation(boolean value)
	{
		addedInformation = value;
		System.out.println(this.toString() + " addedInfo set to" + addedInformation);
	}
	
	public void setEvaluation(int value)
	{
		conflictSolved = true;
		conflictValue = value;
		addedInformation(false);
	}
	
}
